package cn.youfule.dp.strategy;

public class DataSorter {

	public static void sort(Object[] a) throws Exception {
		for(int i=a.length;i>0;i--) {
			for(int j=0;j<i-1;j++) {
				Comparable c1= (Comparable)a[j];
				Comparable c2 = (Comparable)a[j+1];
				if(c1.compareTo(c2) > 0) {
					swap(a,j,j+1);
				}
			}
		}
	}

	private static void swap(Object[] a, int x, int y) {
		Object temp = a[x];
		a[x] = a[y];
		a[y] = temp;
	}

	public static void p(Object[] a) {
		for(int i = 0;i<a.length;i++) {
			System.out.println(a[i]+" ");
		}
	}

}
